import request from "@/utils/http/request";
import {UserVO, UserPageReqVO} from "@/types";

// 查询用户管理列表
export const getUserPageApi = async (params: UserPageReqVO) => {
    return await request({
        url: '/system/user/page', params,
        method: 'GET'
    })
}

// 查询用户详情
export const getUserApi = async (id: number) => {
    return await request({
        url: '/system/user/get?id=' + id,
        method: 'GET'
    })
}

// 新增用户
export const createUserApi = async (data: UserVO) => {
    return await request({
        url: '/system/user/create', data,
        method: 'POST'
    })
}

// 修改用户
export const updateUserApi = async (data: UserVO) => {
    return await request({
        url: '/system/user/update', data,
        method: 'PUT'
    })
}

// 删除用户
export const deleteUserApi = async (id: number) => {
    return await request({
        url: '/system/user/delete?id=' + id,
        method: 'DELETE'
    })
}

// 下载用户导入模板
export const importUserTemplateApi = async () => {
    return await request({
        url: '/system/user/get-import-template',
        method: 'POST'
    })
}

// 用户密码重置
export const resetUserPwdApi = async (id: number, password: string) => {
    const data = {
        id,
        password
    }
    return await request({
        url: '/system/user/update-password', data: data,
        method: 'POST'
    })
}

// 用户状态修改
export const updateUserStatusApi = async (id: number, status: number) => {
    const data = {
        id,
        status
    }
    return await request({
        url: '/system/user/update-status', data: data,
        method: 'POST'
    })
}

// 获取用户精简信息列表
export const getListSimpleUsersApi = async () => {
    return await request({
        url: '/system/user/list-all-simple',
        method: 'GET'
    })
}
